(function(window) {
	var vm;
	var devSN = "";
	var userName = "";
	var commonLocale = dataManager.getLocale();
	function operationPagePulldownRefresh(isPulldownRefresh) {
		var self = this;
		isPulldownRefresh = isPulldownRefresh === undefined ? true : isPulldownRefresh;
		setTimeout(function() {
			isPulldownRefresh && self.endPullDownToRefresh();
		}, 2000);
	}
	
	function saveAndReboot(){
		var btnArray = [vm.$t('btnArray[0]'),vm.$t('btnArray[1]')];
		mui.confirm(vm.$t('confirmBtn[0]'), vm.$t('promptTips'), btnArray, function(e) {
			if (e.index == 1) {
				v3BaseReset.deviceOperation(devSN,1,function(code,data){
					if(code === 0){
						if(data.retCode === 0){
							commonTool.toast(commonLocale.devOperationStatus[0]);
						}else if(data.retCode === 1){
							commonTool.toast(commonLocale.devOperationStatus[1]);
						}else if(data.retCode === 2){
							commonTool.toast(commonLocale.devOperationStatus[2]);
						}else if(data.retCode === 3){
							commonTool.toast(commonLocale.devOperationStatus[3]);
						}else if(data.retCode === 4){
							commonTool.toast(commonLocale.devOperationStatus[4]);
						}else{
							commonTool.toast(commonLocale.devOperationStatus[5]);
						}
					}else{
						commonTool.toast(commonLocale.devOperationFailureTips);
					}
		        });
			}
		});
	}
	
	function directRestart(){
		var btnArray = [vm.$t('btnArray[0]'),vm.$t('btnArray[1]')];
		mui.confirm(vm.$t('confirmBtn[1]'), vm.$t('promptTips'), btnArray, function(e) {
			if (e.index == 1) {
				v3BaseReset.deviceOperation(devSN,0,function(code,data){
					if(code === 0){
						if(data.retCode === 0){
							commonTool.toast(commonLocale.devOperationStatus[0]);
						}else if(data.retCode === 1){
							commonTool.toast(commonLocale.devOperationStatus[1]);
						}else if(data.retCode === 2){
							commonTool.toast(commonLocale.devOperationStatus[2]);
						}else if(data.retCode === 3){
							commonTool.toast(commonLocale.devOperationStatus[3]);
						}else if(data.retCode === 4){
							commonTool.toast(commonLocale.devOperationStatus[4]);
						}else{
							commonTool.toast(commonLocale.devOperationStatus[5]);
						}
					}else{
						commonTool.toast(commonLocale.devOperationFailureTips);
					}
		        });
			}
		});
	}
	
	function mainLinkReconnect(){
		var btnArray = [vm.$t('btnArray[0]'),vm.$t('btnArray[1]')];
		mui.confirm(vm.$t('confirmBtn[2]'), vm.$t('promptTips'), btnArray, function(e) {
			if (e.index == 1) {
				v3BaseReset.mainLinkReconnect(devSN,function(code,data){
					if(code === 0){
						if(data.retCode === 0){
							commonTool.toast(commonLocale.mainLinkReconnectStatus[0]);
						}else{
							commonTool.toast(commonLocale.mainLinkReconnectStatus[1]);
						}
					}else{
						commonTool.toast(commonLocale.devOperationFailureTips);
					}
		        });
			}
		});
	}
	
	function mounted() {
		vm = this;

		$.plusReady(function() {
			devSN = $.util.getDevSN();
			userName = dataManager.getUserName();
			operationPagePulldownRefresh(false);
			
			$('.mui-scroll-wrapper').scroll({
				indicators: true, //是否显示滚动条
				bounce: false,
				deceleration: 0.0005
			});

			$("#manager-scroll").pullToRefresh({
				down: {
					callback: operationPagePulldownRefresh
				}
			});
		});
	}
	
	window.operation = {
		mounted: mounted,
		data: {
			
		},
		methods: {
			saveAndReboot: saveAndReboot,
			directRestart: directRestart,
			mainLinkReconnect: mainLinkReconnect
		}
	};
})(window);